package com.example.lxrbf;

import com.example.lxrbf.db.MySQLiteController;
import com.xqkad.StorageList;

import android.app.*;
import android.os.*;
import android.util.Log;
import android.view.*;
import android.widget.*;
import java.io.*;

public class MainActivity extends Activity {
	private TextView tv3, tv4, tv5;
	public boolean clickenable = true;
	private Lxrbf lxrbf;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		tv3 = (TextView) findViewById(R.id.tv3);
		tv4 = (TextView) findViewById(R.id.tv4);
		tv5 = (TextView) findViewById(R.id.tv5);
		init();
	}


	private void init() {
		String[] path3 = new StorageList(this).getVolumePaths();
		lxrbf = new Lxrbf(this);
	}
	
	public void onClick(View v) {
		if(!clickenable)
			return;
		switch (v.getId()) {
		case R.id.btn1:
			clickenable = false;
			sc("备份中");
			int bf = lxrbf.bf();
			if(bf == -1) {
				sc("备份出错");
			}else sc("完成!");
			clickenable = true;
			break;
		case R.id.btn2:
			clickenable = false;
			sc("恢复中");
			int hf = lxrbf.hf();
			if(hf == -1)
				sc("error");
			clickenable =true;
			break;
		}
	}
	
	public void sc(String s) {
		tv5.setText(s);
	}
	
	public void sca(String s) {
		tv5.append(s);
	}
	
	public void setUI(String tv3str, String tv4str) {
		this.tv3.setText(tv3str);
		this.tv4.setText(tv4str);
	}
}
